package main

import (
	"github.com/gin-gonic/gin"
	"micro/gin-api-gateway/client"
	"micro/gin-api-gateway/handler"
	"micro/gin-api-gateway/middlerware"
)

func main() {
	r := gin.Default()
	v1 := r.Group("/v1")

	//解决回调函数
	randClient := client.GetRandClient()
	userClient := client.GetUserClient()
	getidClient := client.GetGetIdClient()
	apiHandler := handler.GetAPIHandler(randClient, userClient, getidClient)
	//v1.GET("/rand", apiHandler.Rand)
	user := v1.Group("user")

	user.POST("/registry", apiHandler.RegistryUser)
	user.POST("/login", apiHandler.LoginUser)

	user.GET("/rand", middlerware.AuthMiddleware(), apiHandler.Rand)

	v1.GET("/get_id", apiHandler.GetId)

	if err := r.Run(); err != nil {
		panic(err)
	}
}
